package com.itheima.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.UserDao;
import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.jws.soap.SOAPBinding;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @PostConstruct
    public void inir(){
        System.out.println("chuangjianle");
    }
    @Autowired
    private UserDao userDao;
    @Override
    public void save(User user) {
     userDao.save(user);
    }

    @Override
    public void delete(Integer id) {
        userDao.delete(id);
    }

    @Override
    public void update(User user) {
        userDao.update(user);
    }

    @Override
    public User selectByid(Integer id) {
        return userDao.selectByid(id);
    }

    @Override
    public PageInfo<User> selectAll() {
        PageHelper.startPage(1,5);
        List<User> users = userDao.slectAll();
        PageInfo<User> userPageInfo = new PageInfo<>(users);
        return userPageInfo;

    }
}
